<template>
	<view>
		<u-sticky>
			<view>
				<u-tabs :list="list" :is-scroll="false" :current="current" @change="change">
				</u-tabs>
			</view>

		</u-sticky>
		<view v-if="current == 0">
			<!-- <uni-card :title="item.title" :extra="item.addrs" v-for="(item,index) in courseList" :key="index">
				<text class="uni-body" v-html="item.content" style="line-height: 60px;"></text>
				<uni-list>
					<uni-list-item :title="item.attendClassTime"></uni-list-item>
					<uni-list-item :title="item.quittingTime"></uni-list-item>
				</uni-list>
			</uni-card> -->

			<!-- <uni-calendar class="uni-calendar--hook" :selected="info.selected" :showMonth="false" @change="changee" @monthSwitch="monthSwitch" /> -->

			<uni-calendar :clearDate="true" :showMonth="false" :insert="true" :selected="selected" :lunar="false"
				:start-date="'1990-01-01'" :end-date="'2099-01-01'" @monthSwitch="monthSwitch" @change="dateChange">
			</uni-calendar>
		</view>

		<view v-else>
			<uni-card :title="item.title" :extra="item.addrs" v-for="(item, index) in courseList2" :key="index">
				<text class="uni-body" v-html="item.content" style="line-height: 60px;"></text>
				<uni-list>
					<uni-list-item :title="item.attendClassTime"></uni-list-item>
					<uni-list-item :title="item.quittingTime"></uni-list-item>
				</uni-list>
				<view v-show="item.professorId && item.isEvaluate != 1"><button type="primary" size="mini"
						@click="toGowen(item)">调查问卷</button></view>
			</uni-card>
		</view>
	</view>
</template>

<script>
import {
	getMyCourse
} from '@/api/jz/student/info.js';

export default {
	data() {
		return {
			list: [{
				name: '待上课',
				count: 0

			}, {
				name: '已上课'
			}],
			current: 0,
			courseList: [],
			courseList2: [],
			info: {
				lunar: true,
				range: true,
				insert: false,
				selected: []
			},
			selected: [{
				date: '2023-07-04', // date为所需要打点的日期
				type: "abnormal" // abnormal显示为橙色点
			}, {
				date: '2023-07-01',
				type: "normal" // normal显示为蓝色点
			}],
		}
	},
	mounted() {

	},
	onShow() {
		this.getCourse();
	},
	methods: {
		/**
		  * 选中日期的触发事件
		*/
		dateChange: function (e) {
			console.log(e);
		},
		/**
		 *  选中月份的触发事件
		 */
		monthSwitch: function (e) {
			console.log(e);
		},
		open() {
			this.$refs.calendar.open();
		},
		close() {
			console.log('弹窗关闭');
		},
		changee(e) {
			console.log('change 返回:', e);
			// 模拟动态打卡
			console.log(this.info.selected);
			if (this.info.selected.length > 5) return;
			this.info.selected.push({
				date: e.fulldate,
				// info: '打卡'
			});
		},
		confirm(e) {
			console.log('confirm 返回:', e);
		},
		monthSwitch(e) {
			console.log('monthSwitchs 返回:', e);
		},
		toGowen(val) {
			uni.navigateTo({
				url: "/pages/questionnaire/index?courseId=" + val.id
			})
		},
		change(index) {
			this.current = index;
		},
		async getCourse() {
			await getMyCourse(this.studentMyCourseVo).then((res) => {

				for (var i = 0; i < res.waitForClass.length; i++) {
					res.waitForClass[i].attendClassTime = "上课时间：" + res.waitForClass[i].attendClassTime;
					res.waitForClass[i].quittingTime = "下课时间：" + res.waitForClass[i].quittingTime;
					res.waitForClass[i].title = res.waitForClass[i].title + "(" + res.waitForClass[i].professorName + ")";
				}

				for (var i = 0; i < res.quittingTime.length; i++) {
					res.quittingTime[i].attendClassTime = "上课时间：" + res.quittingTime[i].attendClassTime;
					res.quittingTime[i].quittingTime = "下课时间：" + res.quittingTime[i].quittingTime;
					res.quittingTime[i].title = res.quittingTime[i].title + "(" + res.quittingTime[i].professorName + ")";
				}
				this.courseList = res.waitForClass
				this.courseList2 = res.quittingTime
				this.list[0].count = res.waitForClass.length;

			})
		},
	}
}
</script>
<style scoped lang="scss"></style>